home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / CPlus Files / ABUEnvQD.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  5.2 KB  |  222 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABUEnvQD.c
  15.  
  16. NAME
  17.     ABUEnvQD.c, part of the ABox project source code,
  18.     responsible for mix-in handling the AboutBox QD environment stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     12-aug-94    -    ty    -    initial version created/released
  36.     10-mar-95    -    ty    -    1.2 addition of various static methods moved from
  37.                                 ABObject; addition of method for examining
  38.                                 the port, active screen, and pixel depth
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45.  
  46.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  47.                             query methods
  48. */
  49.  
  50. /*===========================================================================*/
  51.  
  52. /*======= Segmentation directives ========*/
  53.  
  54. #ifdef USE_MANUAL_SEGMENTATION
  55. #pragma segment ty
  56. #endif
  57.  
  58. /*============ Header files ==============*/
  59.     
  60. #include     "ABUEnvQD.h"
  61.  
  62. /*=============== Globals ================*/
  63.  
  64. /*================ CODE ==================*/
  65.  
  66.  
  67. /*=============================== ABUEnvQD::ABUEnvQD ================================*/
  68. ABUEnvQD::ABUEnvQD(void)
  69. {
  70.     mVersion = 0;
  71. }    // end ABUEnvQD
  72.  
  73.  
  74. /*=============================== ABUEnvQD::~ABUEnvQD ================================*/
  75. ABUEnvQD::~ABUEnvQD(void)
  76. {
  77.     this->Close();
  78. }    // end ~ABUEnvQD
  79.  
  80.  
  81.  
  82. /*=============================== ABUEnvQD::IsPresent ================================*/
  83. Boolean    ABUEnvQD::IsPresent(void)
  84. {
  85.     if (!this->WasChecked())
  86.     {
  87.         if (this->GestaltAvailable())
  88.         {
  89.             (void)this->CheckGestalt(gestaltQuickdrawVersion);
  90.             this->SetVersion(this->GetResult());
  91.             
  92.             (void)this->CheckGestalt(gestaltQuickdrawFeatures);
  93.             this->IndicatorRef() = true;
  94.         } else {
  95.             this->IndicatorRef() = false;
  96.         } // end if else block
  97.         
  98.         this->CheckedRef() = true;
  99.  
  100.     } // end if block
  101.     return this->IndicatorRef();
  102. }    // end IsPresent
  103.  
  104.  
  105. /*=============================== ABUEnvQD::CheckVersion ================================*/
  106. long    ABUEnvQD::CheckVersion(void)
  107. {
  108.     if (!this->WasChecked())
  109.         (void)this->IsPresent();
  110.     
  111.     return this->VersionRef();
  112. } // end of CheckVersion
  113.  
  114.  
  115.  
  116. /*=============================== ABUEnvQD::CheckFeatures ================================*/
  117. long    ABUEnvQD::CheckFeatures(void)
  118. {
  119.     if (!this->WasChecked())
  120.         (void)this->IsPresent();
  121.     
  122.     return this->ResultRef();
  123. } // end of CheckFeatures
  124.  
  125.  
  126.  
  127. /*=============================== ABUEnvQD::HasColorQD ================================*/
  128. Boolean    ABUEnvQD::HasColorQD(void)
  129. {
  130.     return this->CheckVersion() >= gestalt8BitQD;
  131.  
  132. } // end of HasColorQD
  133.  
  134.  
  135.  
  136. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  137. //
  138. //    returns true if the current GrafPtr supports color qd
  139. //
  140. Boolean
  141. ABUEnvQD::IsColorPort(void) const
  142. {
  143.     return ABUEnvQD::IsColorPort();
  144.     GrafPtr curPort = NULL;
  145.     ::GetPort(&curPort);
  146.     
  147.     return this->IsColorPort(curPort);
  148. }
  149.  
  150.  
  151.  
  152. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  153. //
  154. //    returns true if the current GrafPtr supports color qd
  155. //
  156. Boolean
  157. ABUEnvQD::IsColorPort(void)
  158. {
  159.     GrafPtr curPort = NULL;
  160.     ::GetPort(&curPort);
  161.     
  162.     return ABUEnvQD::IsColorPort(curPort);
  163. }
  164.  
  165.  
  166.  
  167. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  168. //
  169. //    returns true if the current GrafPtr supports color qd
  170. //
  171. Boolean
  172. ABUEnvQD::IsColorPort(GrafPtr inGrafPtr)
  173. {
  174.     // Highest 2 bits of rowBytes are  set for a Color GrafPort
  175.     if (inGrafPtr != NULL)
  176.         return ((inGrafPtr->portBits.rowBytes & 0xC000) == 0xC000);
  177.     else
  178.         return false;
  179. }
  180.  
  181.  
  182.  
  183.  
  184. /*=============================== ABUEnvQD::IsActiveScreenDevice ==================================*/
  185. //
  186. //    returns true if the device is the active device
  187. //
  188. //    is called by:
  189. //        various
  190. //
  191. Boolean
  192. ABUEnvQD::IsActiveScreenDevice(GDHandle inGDevice)
  193. {
  194.     if (inGDevice)
  195.         return (::TestDeviceAttribute(inGDevice, screenDevice) &&
  196.                 ::TestDeviceAttribute(inGDevice, screenActive));
  197.     else
  198.         return false;
  199. }
  200.  
  201.  
  202.  
  203. /*=============================== ABUEnvQD::GetPixelDepth ==================================*/
  204. //
  205. //    GetPixelDepth will return the depth, in pixels, of the
  206. //    given Graphics Device
  207. //
  208. short    
  209. ABUEnvQD::GetPixelDepth(GDHandle inDevice)
  210. {
  211.     
  212.     //    begin here...
  213.     
  214.     if (!inDevice)
  215.         return kABdefaultScreenDepth;
  216.  
  217.     return (*(*inDevice)->gdPMap)->pixelSize;
  218.     
  219. }    //    end of function GetPixelDepth()...
  220.  
  221.  
  222.